package redlib.backend.service.utils;

import org.springframework.beans.BeanUtils;
import org.springframework.util.Assert;
import redlib.backend.dto.ContactsDTO;
import redlib.backend.model.Contacts;
import redlib.backend.utils.FormatUtils;
import redlib.backend.vo.ContactsVO;

import java.util.Map;

public class ContactsUtils {
    public static void validateContacts(ContactsDTO contactsDTO) {
        FormatUtils.trimFieldToNull(contactsDTO);
        Assert.notNull(contactsDTO, "文章输入数据不能为空");
        Assert.hasText(contactsDTO.getContactsName(), "文章名称不能为空");
    }
    public static ContactsVO convertToVO(Contacts contacts, Map<Integer, String> nameMap) {
        ContactsVO ContactsVO = new ContactsVO();
        BeanUtils.copyProperties(contacts, ContactsVO);

        ContactsVO.setCreatedByDesc(nameMap.get(contacts.getCreatedBy()));
        return ContactsVO;
    }
}


